﻿@*新增学生页面*@
@using EasyCourse.Model;
@{
    Layout = null;
    CommonPageInfo pageInfo = ViewData[CommonViewDataKey.CommonPageInfo] as CommonPageInfo;
    string para = "CourseId=" + pageInfo.CourseId;
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>新增学生用户</title>
    @Html.Partial("~/Views/Share/PublicHeader.cshtml")
</head>
<body>
    @Html.Partial("~/Views/Share/PublicTopNav4Teacher.cshtml")
    <div class="container">
        <div class="row">
            <h1 class="topTitle-h1">@pageInfo.CourseName<br><small>广州中医药大学康复治疗微课程网络学习平台</small></h1>
        </div>
    </div>
    @*导航菜单*@
    @Html.Partial("~/Views/Share/PublicTeacherNaviMenu.cshtml", 3)
    <div class="container mainwrap">
        <div class="row">
            <div class="col-xs-2">
                <div class="dropdown theme-dropdown clearfix">
                    <a id="dropdownMenu1" href="#" role="button" class="sr-only dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>
                    <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
                        <li role="presentation">
                            <a role="menuitem" tabindex="-1" href="/UserInfo/StudentList?@para"><span class="glyphicon glyphicon-list"></span> 学生用户列表</a>
                        </li>
                        <li role="presentation" class="divider"></li>
                        <li class="active" role="presentation">
                            <a role="menuitem" tabindex="-1" href="javascript:void(0)"><span class="glyphicon glyphicon-user"></span> 新增学生用户</a>
                        </li>
                        <li role="presentation" class="divider"></li>
                        <li role="presentation">
                            <a role="menuitem" tabindex="-1" href="/UserInfo/StudentGrpList?@para"><span class="glyphicon glyphicon-list"></span> 学生用户组列表</a>
                        </li>
                        <li role="presentation" class="divider"></li>
                        <li role="presentation">
                            <a role="menuitem" tabindex="-1" href="/UserInfo/AddStudentGrp?@para"><span class="glyphicon glyphicon-plus"></span> 新增学生用户组</a>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="col-xs-10">
                <div class="panel panel-default mainwrap-part">
                    <div class="panel-heading">
                        <ol class="breadcrumb">
                            <li>学生用户管理</li>
                            <li class="active">新增学生用户</li>
                        </ol>
                    </div>
                    <div class="panel-body">
                        <ul id="myTab" class="nav nav-tabs">
                            <li class="active">
                                <a href="#home" data-toggle="tab">单个增加</a>
                            </li>
                            <li><a href="#ios" data-toggle="tab">批量导入</a></li>
                        </ul>
                        <div id="myTabContent" class="tab-content mt15">
                            <div class="tab-pane fade in active" id="home">
                                <div class="row">
                                    <form role="form" id="JaddStdForm">
                                        <div class="form-group clearfix">
                                            <label class="control-label col-xs-2">学号：</label>
                                            <div class="col-xs-6">
                                                <input type="text" class="form-control" id="Jaccount" placeholder="请输入学号">
                                            </div>
                                            <div class="col-xs-4"></div>
                                        </div>
                                        <div class="form-group clearfix">
                                            <label class="control-label col-xs-2">姓名：</label>
                                            <div class="col-xs-6">
                                                <input type="text" class="form-control" id="JrealName" placeholder="请输入学生姓名">
                                            </div>
                                            <div class="col-xs-4"></div>
                                        </div>
                                        <div class="form-group clearfix">
                                            <label class="control-label col-xs-2">初始密码：</label>
                                            <div class="col-xs-6">
                                                <input type="text" class="form-control" id="Jpassword" placeholder="请输入初始密码">
                                            </div>
                                            <div class="col-xs-4"></div>
                                        </div>
                                        <div class="form-group clearfix">
                                            <label class="control-label col-xs-2">确认密码：</label>
                                            <div class="col-xs-6">
                                                <input type="text" class="form-control" id="Jpassword2" placeholder="请再次输入密码">
                                            </div>
                                            <div class="col-xs-4"></div>
                                        </div>
                                        <div class="form-group clearfix">
                                            <div class="col-xs-offset-2 col-xs-10">
                                                <button type="button" id="JaddStd" class="btn btn-success">新增</button>
                                                <button type="button" onclick="history.go(-1)" class="btn btn-success btn-md"><span class="glyphicon glyphicon-arrow-left"></span>返回</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                            <div class="tab-pane fade" id="ios">
                                <div class="row">
                                    <form role="form">
                                        <div class="form-group clearfix">
                                            <label class="control-label col-xs-2">Excel批量导入：</label>
                                            <div class="col-xs-6">
                                                <input name="fileName" id="JfileName" class="form-control mb10" readonly="readonly" />                                            
                                                <input id="file_upload" name="file_upload" type="file" class="form-control input-sm">
                                            </div>
                                            <div class="col-xs-4"></div>
                                        </div>
                                        <div class="form-group clearfix">
                                            <label class="control-label col-xs-2">批量导入模版：</label>
                                            <div class="col-xs-6">
                                                <a class="red" href="../../res/template/批量导入学生信息模板.xlt" >Excel模版下载</a>
                                            </div>
                                            <div class="col-xs-4"></div>
                                        </div>
                                        <div class="form-group clearfix">
                                            <label class="control-label col-xs-2">初始密码：</label>
                                            <div class="col-xs-6">
                                                <input type="text" class="form-control" id="Jpassword3" placeholder="请输入初始密码">
                                            </div>
                                            <div class="col-xs-4"></div>
                                        </div>
                                        <div class="form-group clearfix">
                                            <label class="control-label col-xs-2">确认密码：</label>
                                            <div class="col-xs-6">
                                                <input type="text" class="form-control" id="Jpassword4" placeholder="请再次输入密码">
                                            </div>
                                            <div class="col-xs-4"></div>
                                        </div>
                                        <div class="form-group clearfix">
                                            <div class="col-xs-offset-2 col-xs-10">
                                                <button type="button" id="JaddStd2" class="btn btn-success">新增</button>
                                                <button type="button" onclick="history.go(-1)" class="btn btn-success btn-md"><span class="glyphicon glyphicon-arrow-left"></span>返回</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    @Html.Partial("~/Views/Share/PublicFooter.cshtml")
    @Html.Partial("~/Views/Share/PublicCommonJs.cshtml")
    <!-- <script type="text/javascript" src="../Content/uploadify/jquery.uploadify.min.js?V=@DateTime.Now.Ticks"></script>
    <link href="../Css/uploadify.css" rel="stylesheet" /> -->
    
    <link href="../Content/UpLoadFive/uploadifive.css" rel="stylesheet" /> 
    <script type="text/javascript" src="../Content/UpLoadFive/jquery.uploadifive.min.js?V=@DateTime.Now.Ticks"></script>
    <script type="text/javascript">
        //上传文件
        var _attachmentUrl = null;
        // $(function () {
        //     $("#file_upload").uploadify({
        //         'queueSizeLimit': 1,
        //         //fileType代表文件类型的值可能有:   Image 、 OtherFile 、 Temp
        //         'formData': { 'fileType': 'OtherFile' },
        //         'buttonText': '请选择上传文件',
        //         'swf': '../Content/uploadify/uploadify.swf',
        //         'uploader': '@Url.Action("UpLoad", "Base")',
        //         'onUploadSuccess': function (file, data, response) {
        //             var json = $.parseJSON(data);
        //             if (json.result) {
        //                 _attachmentUrl = json.message; //文件保存的地址
        //                 $("#JfileName").val(file.name);
        //                 $("#JfileName").attr("data-fileUrl", _attachmentUrl);
        //             }
        //             else {
        //                 showTips.open(json.message);
        //             }
        //         }
        //     });
        // }); 

        $(function () {
            $("#file_upload").uploadifive({
                'queueSizeLimit': 1,
                //fileType代表文件类型的值可能有:   Image 、 OtherFile 、 Temp
                'formData': { 'fileType': 'OtherFile' },
                'buttonText': '请选择上传文件',
                'swf': '../Content/uploadify/uploadify.swf',
                'uploadScript': '@Url.Action("UpLoad", "Base")',
                'onUploadComplete': function (file, data, response) {
                    var json = $.parseJSON(data);
                    if (json.result) {
                        _attachmentUrl = json.message; //文件保存的地址
                        $("#JfileName").val(file.name);
                        $("#JfileName").attr("data-fileUrl", _attachmentUrl);
                    }
                    else {
                        showTips.open(json.message);
                    }
                }
            });
        }); 

    </script>
    <script>
        (function () {
            $("#JaddStd").bind("click", function () {
                var Jaccount = $("#Jaccount").val(),
                JrealName = $("#JrealName").val(),
                Jpassword = $("#Jpassword").val(),
                Jpassword2 = $("#Jpassword2").val();
                $.easyPost("@Url.Action("AddStudent", "UserInfo")", {
                    "Account": Jaccount,
                    "RealName": JrealName,
                    "Password": Jpassword,
                    "Password2": Jpassword2
                }, function (data) {
                    if (data.result) {
                        showTips.open("添加成功！");
                        $("#JaddStdForm")[0].reset();
                        return;
                    } else {
                        showTips.open(data.message);
                        return;
                    }
                }, "json");
            })
            $("#JaddStd2").bind("click", function () {
                var Jfile = $("#JfileName").attr("data-fileUrl"),
                    Jpassword3 = $("#Jpassword3").val(),
                    Jpassword4 = $("#Jpassword4").val();
                $.easyPost("@Url.Action("AddStudentList", "UserInfo")", {
                    "FilePath": Jfile, 
                    "Password": Jpassword3,
                    "Password2": Jpassword4
                }, function (data) {
                    if (data.result) {
                        showTips.open("添加成功！");
                        return;
                    } else {
                        showTips.open(data.message);
                        return;
                    }
                }, "json")
            })
        })()
    </script>
</body>
</html>